#ifndef token_h_20130728_1104_04
#define token_h_20130728_1104_04

class Token {
public:
  Token() : symbol_ptr_(nullptr) {
  }

  virtual ~Token() {
    if(symbol_ptr_ != nullptr) {
      delete symbol_ptr_;
    }
  }
  const int& id() { 
    return this->id_; 
  }
  Token& id(const int& id) { 
    this->id_ = id; 
    return *this; 
  }
  const string& symbol() { 
    static const string empty_symbol();
    if(this->symbol_ptr_ == nullptr) {
      return empty_symbol;
    } else {
      return *symbol_ptr_;
    }
  }
  Token& symbol(const string& s) {
    if(symbol_ptr_ == nullptr) {
      symbol_ptr_ = new string(s);
    } else {
      *symbol_ptr_ = s;
    }
    return *this;
  }
private:
  int id_;
  string* symbol_ptr_;
};

#endif//token_h_20130728_1104_04
